# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Tharre <tharre3@gmail.com>

pkgname=age
pkgver=1.1.1
pkgrel=1
pkgdesc='A simple, modern and secure file encryption tool'
arch=('loong64' 'x86_64')
url="https://github.com/FiloSottile/$pkgname"
license=('BSD')
depends=('glibc')
makedepends=('go')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha512sums=('bee02208453982b6403382c1e351ba28cbe80942702e7a35de89c3ae9a640c26ad1ee8239feb3726eac5df4210a5fc6375d40623162cad033965bd2eb0f7ce1e')

build() {
    cd "$pkgname-$pkgver"
    go build \
      -trimpath \
      -buildmode=pie \
      -mod=readonly \
      -modcacherw \
      -ldflags "-X main.Version=$pkgver -linkmode external -extldflags \"$LDFLAGS\"" \
      -o . ./...
}

check() {
    cd "$pkgname-$pkgver"
    go test ./...
}

package() {
    cd "$pkgname-$pkgver"
    install -Dm755 -t "$pkgdir/usr/bin/" age age-keygen
    install -Dm644 -t "$pkgdir/usr/share/man/man1/" doc/age.1 doc/age-keygen.1
    install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
